﻿/*----------------------------------------------------------------
           // Copyright (C) 2008 安华顺通(北京)科技有限公司
           // 版权所有。 
           //
           // 文件名：TypeProperties.cs
           // 文件功能描述：容纳所有类型的属性类。
           //
           // 
           // 创建标识：杨波
           //
           // 修改标识：杨波20080902
           // 修改描述：添加MenuItem的属性类。
           //
           // 修改标识：杨波20080903
           // 修改描述：增加Label属性用LabelEditor编辑的功能，增加MenuProperty类。
 
           // 修改标识：
           // 修改描述：  
 
           // 修改标识： 
           // 修改描述：
 * 
 * 
//----------------------------------------------------------------*/

#region UsingStatements

using System.ComponentModel;
using System.Drawing.Design;
using System.IO;
using System.Runtime.Serialization;

#endregion

namespace RuleCode.ObjectTree
{

    #region Base

    /// <summary>
    /// NameProperty class在BaseProperty的基础上增加了Name和Label属性。
    /// </summary>
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class NameProperty : BaseProperty
    {
        // the property class add name property
        public NameProperty(string id)
            : base(id)
        {
            //this.ID = id;
        }

        public NameProperty()
        {
        }

        private string name = string.Empty;

        [DataMember, ReadOnly(true), Description("The name of application object")]
        public string Name
        {
            set { name = value; }
            get { return name; }
        }

        /// <summary>
        /// Label property.
        /// </summary>
        private string label = string.Empty;

        [DataMember, Editor(typeof(LabelPropertyEditor), typeof(UITypeEditor)),
         Description("The name commonly used for  application object")]
        public string Label
        {
            set { label = value; }
            get { return label; }
        }

        /// <summary>
        /// LabelText
        /// </summary>
        private string labelText = string.Empty;

        [DataMember, ReadOnly(true)]
        public string LabelText
        {
            set { labelText = value; }
            get { return labelText; }
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class HelpTextProperty : NameProperty
    {
        public HelpTextProperty()
        {
        }

        public HelpTextProperty(string id)
            : base(id)
        {
        }

        private string helpLabel = string.Empty;

        [DataMember, Editor(typeof(LabelPropertyEditor), typeof(UITypeEditor)),
         Description("The ID of the HelpText Field")]
        public string HelpLabel
        {
            set { helpLabel = value; }
            get { return helpLabel; }
        }

        private string helpText = string.Empty;

        [DataMember, ReadOnly(true), Description("The help text for application object")]
        public string HelpText
        {
            set { helpText = value; }
            get { return helpText; }
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class MethodProperty : BaseProperty
    {
        private string content;

        public MethodProperty()
        {
        }

        public MethodProperty(string id)
            : base(id)
        {
        }

        [DataMember, Editor(typeof(SysPropertyMethodUIEditor), typeof(UITypeEditor)),
         Description("The name commonly used for  application object"), ReadOnly(true)]
        public string Content
        {
            set { content = value; }
            get { return content; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(MethodProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #region EDT

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTProperty : HelpTextProperty
    {
        //the EDTProperty class add extends and aligment properties.
        public EDTProperty()
        {
        }

        public EDTProperty(string id)
            : base(id)
        {
            //this.ID = id;
        }

        /*private string name;
        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }*/
        /* private string helpText;
         [DataMember]
         public string HelpText
         {
             set { helpText = value; }
             get { return helpText; }
         }*/
        private string formHelp = string.Empty;

        [DataMember, Description("The form to lookup from fields in forms")]
        public string FormHelp
        {
            set { formHelp = value; }
            get { return formHelp; }
        }

        private string arrayLength;

        [DataMember, ReadOnly(true), Description("Number of element in array")]
        public string ArrayLength
        {
            set { arrayLength = value; }
            get { return arrayLength; }
        }

        private string displayLength = PropertyValue.Auto;

        [DataMember, Description("Number of characters to show in form/report")]
        public string DisplayLength
        {
            set { displayLength = value; }
            get { return displayLength; }
        }

        private string buttonImage = PropertyValue.Arrow;

        [DataMember, Description("The image to appear on a lookup button in forms"),
         TypeConverter(typeof(EDTButtonImage))]
        public string ButtonImage
        {
            set { buttonImage = value; }
            get { return buttonImage; }
        }

        private string extends = string.Empty;

        [DataMember, Description("The object to be inherited")]
        public string Extends
        {
            set { extends = value; }
            get { return extends; }
        }

        private string alignment = PropertyValue.Auto;

        [TypeConverter(typeof(AlignmentCollection)), DataMember, Description("Alignment of value displayed in control")
        ]
        public string Alignment
        {
            set { alignment = value; }
            get { return alignment; }
        }

        protected string edtType;

        [DataMember, ReadOnly(true), Description("The primitive type name")]
        public string EDTType
        {
            get { return edtType; }
            set { edtType = value; }
        }

        //应使用override而不是new，以便调用方法时能使用最新的方法版本。
        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTStringProperty : EDTProperty
    {
        public EDTStringProperty(string id)
            : base(id)
        {
            //this.ID = id;
            EDTType = "TString";
        }

        public EDTStringProperty()
        {
            EDTType = "TString";
        }


        private string displayHeight = PropertyValue.Auto;

        [DataMember, Description("Number of lines to show in form/report")]
        public string DisplayHeight
        {
            set { displayHeight = value; }
            get { return displayHeight; }
        }

        private uint stringSize = 20;

        [DataMember, Description("Length of line in number of characters")]
        public uint StringSize
        {
            set { stringSize = value; }
            get { return stringSize; }
        }

        private string adjustment = PropertyValue.Auto;

        [DataMember, Description("Relational characteristics of text in terms of alignment"),
         TypeConverter(typeof(AlignmentCollection))]
        public string Adjustment
        {
            set { adjustment = value; }
            get { return adjustment; }
        }

        private string changeCase = PropertyValue.None;

        [DataMember, Description("Changed case of input text"), TypeConverter(typeof(EDTStringChangeCase))]
        public string ChangeCase
        {
            set { changeCase = value; }
            get { return changeCase; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTStringProperty));
            FileStream writer = getFileWriter();

            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTIntProperty : EDTProperty
    {
        public EDTIntProperty(string id)
            : base(id)
        {
            //this.ID = id;
            EDTType = "TInt";
        }

        public EDTIntProperty()
        {
            EDTType = "TInt";
        }


        private string signDisplay = PropertyValue.Auto;

        [DataMember, Description("Type of nagative sign display"), TypeConverter(typeof(EDTIntSignDisplay))]
        public string SignDisplay
        {
            set { signDisplay = value; }
            get { return signDisplay; }
        }

        private string rotateSign = PropertyValue.Auto;

        [DataMember, Description("Invert the sign for the value in control"), TypeConverter(typeof(EDTIntRotateSign))]
        public string RotateSign
        {
            set { rotateSign = value; }
            get { return rotateSign; }
        }

        private string showZero = PropertyValue.No;

        [DataMember, Description("Show the value when zero."), TypeConverter(typeof(EDTIntShowZero))]
        public string ShowZero
        {
            set { showZero = value; }
            get { return showZero; }
        }

        private string displaceNegative = PropertyValue.Auto;

        [DataMember, Description("Move the value displayed in the grid control if nagative")]
        public string DisplaceNegative
        {
            set { displaceNegative = value; }
            get { return displaceNegative; }
        }

        private string allowNagative = PropertyValue.Auto;

        [DataMember, Description("Whether the control accept nagative value"),
         TypeConverter(typeof(EDTIntAllowNagative))]
        public string AllowNagative
        {
            set { allowNagative = value; }
            get { return allowNagative; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTIntProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTRealProperty : EDTIntProperty
    {
        public EDTRealProperty(string id)
            : base(id)
        {
            //this.ID = id;
            EDTType = "TDouble";
        }

        public EDTRealProperty()
        {
            EDTType = "TDouble";
        }

        private string thousandSeparator = PropertyValue.Auto;

        [DataMember, Description("Symbol used to separate thousands"), TypeConverter(typeof(EDTRealThousandSeparator))]
        public string ThousandSeparator
        {
            set { thousandSeparator = value; }
            get { return thousandSeparator; }
        }

        private string decimalSeparator = PropertyValue.Auto;

        [DataMember, Description("Symbol used to separate decimal"), TypeConverter(typeof(EDTRealDecimalSeparator))]
        public string DecimalSeparator
        {
            set { decimalSeparator = value; }
            get { return decimalSeparator; }
        }

        private string noOfSeparator = PropertyValue.Auto;

        [DataMember, Description("Number of decimals displayed")]
        public string NoOfSeparator
        {
            set { noOfSeparator = value; }
            get { return noOfSeparator; }
        }

        private string autoInsSeparator = PropertyValue.Auto;

        [DataMember, Description("Whether the system insert a decimal automately"),
         TypeConverter(typeof(EDTRealInsSeparator))]
        public string AutoInsSeparator
        {
            set { autoInsSeparator = value; }
            get { return autoInsSeparator; }
        }

        private string formatMST = PropertyValue.Auto;

        [DataMember, Description("Whether format the content as standard currency"),
         TypeConverter(typeof(EDTRealFormatMST))]
        public string FormatMST
        {
            set { formatMST = value; }
            get { return formatMST; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTRealProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTDateProperty : EDTProperty
    {
        public EDTDateProperty()
        {
            EDTType = "TDate";
        }

        public EDTDateProperty(string id)
            : base(id)
        {
            EDTType = "TDate";
        }


        private string dateFormat = PropertyValue.Auto;

        [DataMember, Description("Date format")]
        public string DateFormate
        {
            set { dateFormat = value; }
            get { return dateFormat; }
        }

        private string dateSeparator = PropertyValue.Auto;

        [DataMember, Description("Date separators")]
        public string DateSeparator
        {
            set { dateSeparator = value; }
            get { return dateSeparator; }
        }

        private string dateYear = PropertyValue.Auto;

        [DataMember, Description("Format for year in a date")]
        public string DateYear
        {
            set { dateYear = value; }
            get { return dateYear; }
        }

        private string dateMonth = PropertyValue.Auto;

        [DataMember, Description("Format for month in a date")]
        public string DateMonth
        {
            set { dateMonth = value; }
            get { return dateMonth; }
        }

        private string dateDay = PropertyValue.Auto;

        [DataMember, Description("Format for day in a date")]
        public string DateDay
        {
            set { dateDay = value; }
            get { return dateDay; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTDateProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTTimeProperty : EDTProperty
    {
        public EDTTimeProperty()
        {
            EDTType = "TTime";
        }

        public EDTTimeProperty(string id)
            : base(id)
        {
            EDTType = "TTime";
        }


        private string timeFormat = PropertyValue.Auto;

        [DataMember, Description("Time format")]
        public string TimeFormat
        {
            set { timeFormat = value; }
            get { return timeFormat; }
        }

        private string timeSeparator = PropertyValue.Auto;

        [DataMember, Description("Time separators")]
        public string TimeSeparator
        {
            set { timeSeparator = value; }
            get { return timeSeparator; }
        }

        private string timeHours = PropertyValue.Auto;

        [DataMember, Description("Format for hour in a time")]
        public string TimeHours
        {
            set { timeHours = value; }
            get { return timeHours; }
        }

        private string timeMinutes = PropertyValue.Auto;

        [DataMember, Description("Format for minute in a time")]
        public string TimeMinutes
        {
            set { timeMinutes = value; }
            get { return timeMinutes; }
        }

        private string timeSeconds = PropertyValue.Auto;

        [DataMember, Description("Format for second in a time")]
        public string TimeSeconds
        {
            set { timeSeconds = value; }
            get { return timeSeconds; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTTimeProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTEnumProperty : EDTProperty
    {
        public EDTEnumProperty()
        {
            EDTType = EDTTypes.EDTTypeEnum;
        }

        public EDTEnumProperty(string id)
            : base(id)
        {
            EDTType = EDTTypes.EDTTypeEnum;
        }


        private string enumType = string.Empty;

        [DataMember, Description("Define the base enum type"), TypeConverter(typeof(EnumTypeCollection))]
        public string EnumType
        {
            set { enumType = value; }
            get { return enumType; }
        }

        private string style = PropertyValue.Auto;

        [DataMember, Description("How to display field"), TypeConverter(typeof(BaseEnumStyle))]
        public string Style
        {
            set { style = value; }
            get { return style; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTEnumProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTContainerProperty : EDTProperty
    {
        public EDTContainerProperty()
        {
            EDTType = "TContainer";
        }

        public EDTContainerProperty(string id)
            : base(id)
        {
            EDTType = "TContainer";
        }


        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTContainerProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTInt64Property : EDTIntProperty
    {
        public EDTInt64Property()
        {
            EDTType = "TInt64";
        }

        public EDTInt64Property(string id)
            : base(id)
        {
            EDTType = "TInt64";
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTInt64Property));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class EDTRelationProperty : BaseProperty
    {
        private string table = string.Empty;
        private string relatedField = string.Empty;
        private string queryType = string.Empty;

        public EDTRelationProperty()
        {
        }

        public EDTRelationProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(TableCollection)), Description("Specify the reference table for the field")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        [DataMember, TypeConverter(typeof(TableFieldCollection)), Description("Select the field to relate to")]
        public string RelatedField
        {
            set { relatedField = value; }
            get { return relatedField; }
        }
        [DataMember, ReadOnly(true)]
        public string QueryType
        {
            set { queryType = value; }
            get { return queryType; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(EDTRelationProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #region Table

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableProperty : HelpTextProperty
    {
        public TableProperty()
        {
        }

        public TableProperty(string id)
            : base(id)
        {
        }

        private string formRef = string.Empty;

        [DataMember, Description("Name of Display Menu Item that gets called when reference it made to this table")]
        public string FormRef
        {
            set { formRef = value; }
            get { return formRef; }
        }

        private string titleField = string.Empty;

        [DataMember, Description("Field used in the title on forms")]
        public string TitleField
        {
            set { titleField = value; }
            get { return titleField; }
        }

        private string titleField2 = string.Empty;

        [DataMember, Description("Field used in the title on forms")]
        public string TitleField2
        {
            set { titleField2 = value; }
            get { return titleField2; }
        }

        private bool temporary;

        [DataMember, Description("Whether create temporary table? ")]
        public bool Temporary
        {
            set { temporary = value; }
            get { return temporary; }
        }

        private string tableContents = PropertyValue.NotSpecified;

        [DataMember, TypeConverter(typeof(TableContent)), Description("Define which type of data the table contains")]
        public string TableContents
        {
            set { tableContents = value; }
            get { return tableContents; }
        }

        private bool systemTable;

        [DataMember, Description("Whether the table is system table")]
        public bool SystemTable
        {
            set { systemTable = value; }
            get { return systemTable; }
        }

        private string maxAcessMode = PropertyValue.Delete;

        [DataMember, TypeConverter(typeof(MaxAccessMode)), Description("Define the access mode on the table")]
        public string MaxAcessMode
        {
            set { maxAcessMode = value; }
            get { return maxAcessMode; }
        }

        private string cacheLookUp = PropertyValue.None;

        [DataMember, TypeConverter(typeof(TableCacheLookUp)), Description("Cache select results")]
        public string CachelookUp
        {
            set { cacheLookUp = value; }
            get { return cacheLookUp; }
        }

        private bool createRecIdIndex = true;

        [DataMember, Description("Create the RecId index automatically?")]
        public bool CreateRecIdIndex
        {
            set { createRecIdIndex = value; }
            get { return createRecIdIndex; }
        }

        private bool saveDataPerCompany = true;

        [DataMember, Description("Save the data per company?")]
        public bool SaveDataPerCompany
        {
            set { saveDataPerCompany = value; }
            get { return saveDataPerCompany; }
        }

        private string primaryIndex;

        [DataMember]
        public string PrimaryIndex
        {
            set { primaryIndex = value; }
            get { return primaryIndex; }
        }

        private string clusterIndex;

        [DataMember]
        public string ClusterIndex
        {
            set { clusterIndex = value; }
            get { return clusterIndex; }
        }

        private bool modifiedDate;

        [DataMember, Browsable(false)]
        public bool ModefiedDate
        {
            set { modifiedDate = value; }
            get { return modifiedDate; }
        }

        private bool modifiedTime;

        [DataMember, Browsable(false)]
        public bool ModifiedTime
        {
            set { modifiedTime = value; }
            get { return modifiedTime; }
        }

        private bool modifiedBy;

        [DataMember, Browsable(false)]
        public bool ModifiedBy
        {
            set { modifiedBy = value; }
            get { return modifiedBy; }
        }

        private bool modifiedTransactionId;

        [DataMember, Browsable(false)]
        public bool ModifiedTransactionId
        {
            set { modifiedTransactionId = value; }
            get { return modifiedTransactionId; }
        }

        private bool createdDate;

        [DataMember, Browsable(false)]
        public bool CreatedDate
        {
            set { createdDate = value; }
            get { return createdDate; }
        }

        private bool createdTime;

        [DataMember, Browsable(false)]
        public bool CreatedTime
        {
            set { createdTime = value; }
            get { return createdTime; }
        }

        private bool createdBy;

        [DataMember, Browsable(false)]
        public bool CreatedBy
        {
            set { createdBy = value; }
            get { return createdBy; }
        }

        private bool createdTransactionId;

        [DataMember, Browsable(false)]
        public bool CreatedTransactionId
        {
            set { createdTransactionId = value; }
            get { return createdTransactionId; }
        }

        //public override void SerializeToXML()
        //{
        //    DataContractSerializer ser =
        //        new DataContractSerializer(typeof(TableProperty));
        //    FileStream writer = getFileWriter();
        //    ser.WriteObject(writer, this);
        //    writer.Close();
        //}
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldProperty : HelpTextProperty
    {
        public TableFieldProperty()
        {
            AllowEdit = true;
        }

        public TableFieldProperty(string id)
            : base(id)
        {
            AllowEdit = true;
        }

        private string groupPrompt = string.Empty;

        [DataMember, Description("Prompt text if the field belong to a group")]
        public string GroupPrompt
        {
            set { groupPrompt = value; }
            get { return groupPrompt; }
        }

        private bool saveContents = true;

        [DataMember, Description("Save field content to disk")]
        public bool SaveContents
        {
            set { saveContents = value; }
            get { return saveContents; }
        }

        private bool mandatory;

        [DataMember, Description("Is the field mandatory?")]
        public bool Mandatory
        {
            set { mandatory = value; }
            get { return mandatory; }
        }

        private bool allowEditOnCreate = true;

        [DataMember, Description("If a entry in the field allowed during the creating of new record")]
        public bool AllowEditOnCreate
        {
            set { allowEditOnCreate = value; }
            get { return allowEditOnCreate; }
        }

        private bool allowEdit = true;

        [DataMember, Description("Whether the field allowed to edit?")]
        public bool AllowEdit
        {
            get { return allowEdit; }
            set { allowEdit = value; }
        }

        private bool visible = true;

        [DataMember, Description("Is the field displayed?")]
        public bool Visible
        {
            set { visible = value; }
            get { return visible; }
        }

        private string aliasFor = string.Empty;

        [DataMember, Description("Select which field this field is alias for")]
        public string AliasFor
        {
            set { aliasFor = value; }
            get { return aliasFor; }
        }

        private string extendedDataType = string.Empty;

        [DataMember, Description("The field extended data type")]
        public string ExtendedDataType
        {
            set { extendedDataType = value; }
            get { return extendedDataType; }
        }

        private string type = string.Empty;

        [DataMember, ReadOnly(true)]
        public string FieldType
        {
            set { type = value; }
            get { return type; }
        }

        //public override void SerializeToXML()
        //{
        //    DataContractSerializer ser =
        //        new DataContractSerializer(typeof(TableFieldProperty));
        //    FileStream writer = getFileWriter();
        //    ser.WriteObject(writer, this);
        //    writer.Close();
        //}
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldGroupProperty : NameProperty
    {
        public TableFieldGroupProperty()
        {
        }

        public TableFieldGroupProperty(string id)
            : base(id)
        {
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldGroupProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class GroupFieldProperty : BaseProperty
    {
        private string dataField = string.Empty;

        public GroupFieldProperty()
        {
        }

        public GroupFieldProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(TableGroupFieldPropertyList)),
         Description("Field in table used as data source")]
        public string DataField
        {
            set { dataField = value; }
            get { return dataField; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(GroupFieldProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableIndexProperty : NameProperty
    {
        public bool allowDuplicates = true;
        public bool enabled = true;

        public TableIndexProperty()
        {
        }

        public TableIndexProperty(string id)
            : base(id)
        {
        }

        [DataMember, Description("Allows index to contain duplicate keys")]
        public bool AllowDuplicates
        {
            set { allowDuplicates = value; }
            get { return allowDuplicates; }
        }

        [DataMember, Description("Yes means speed up data acces.No means index is not created and disk space is saved")]
        public bool Enabled
        {

            set { enabled = value; }
            get { return enabled; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableIndexProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableIndexFieldProperty : GroupFieldProperty
    {
        public TableIndexFieldProperty()
        {
        }

        public TableIndexFieldProperty(string id)
            : base(id)
        {
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableIndexFieldProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableRelationProperty : NameProperty
    {
        private string table = string.Empty;
        private bool validate;

        public TableRelationProperty()
        {
        }

        public TableRelationProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(TableCollection)), Description("Specify the reference table for the field")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        [DataMember, Description("Validate the reference when entering fields in forms?")]
        public bool Validate
        {
            set { validate = value; }
            get { return validate; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableRelationProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableRelationFieldProperty : BaseProperty
    {
        public string field = string.Empty;
        public string relatedField = string.Empty;

        public TableRelationFieldProperty()
        {
        }

        public TableRelationFieldProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(TableRelationField)),
         Description("Select the field to be part of the relationship")]
        public string Field
        {
            set { field = value; }
            get { return field; }
        }

        [DataMember, TypeConverter(typeof(TableRelationRelatedField)), Description("Select the field to relate to")]
        public string RelatedField
        {
            set { relatedField = value; }
            get { return relatedField; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableRelationFieldProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableDeleteActionProperty : BaseProperty
    {
        private string table = string.Empty;
        private string deleteAction = string.Empty;

        public TableDeleteActionProperty()
        {
        }

        public TableDeleteActionProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(TableCollection)), Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        [DataMember, TypeConverter(typeof(TableDeleteAction)), Description("Action in table when a record is deleted")]
        public string DeleteAction
        {
            set { deleteAction = value; }
            get { return deleteAction; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableDeleteActionProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldStringProperty : TableFieldProperty
    {
        public TableFieldStringProperty()
        {
            FieldType = "TString";
        }

        public TableFieldStringProperty(string id)
            : base(id)
        {
            FieldType = "TString";
        }

        [DataMember, ReadOnly(true), Description("The length of field")]
        public uint StringSize { set; get; }

        [DataMember, ReadOnly(true), Description("Relational characteristics of text in terms of alignment")]
        public string Adjustment { set; get; }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldStringProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldRealProperty : TableFieldProperty
    {
        private string fieldUpdate = "Absolute";

        public TableFieldRealProperty()
        {
            FieldType = "TDouble";
        }

        public TableFieldRealProperty(string id)
            : base(id)
        {
            FieldType = "TDouble";
        }

        [DataMember, TypeConverter(typeof(TableFieldUpdate)), Description("Define the update type")]
        public string FieldUpdate
        {
            set { fieldUpdate = value; }
            get { return fieldUpdate; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldRealProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldIntProperty : TableFieldProperty
    {
        private string fieldUpdate = "Absolute";

        public TableFieldIntProperty()
        {
            FieldType = "TInt";
        }

        public TableFieldIntProperty(string id)
            : base(id)
        {
            FieldType = "TInt";
        }

        [DataMember, TypeConverter(typeof(TableFieldUpdate)), Description("Define the update type")]
        public string FieldUpdate
        {
            set { fieldUpdate = value; }
            get { return fieldUpdate; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldIntProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldEnumProperty : TableFieldProperty
    {
        private string enumType = string.Empty;

        public TableFieldEnumProperty()
        {
            FieldType = "TEnum";
        }

        public TableFieldEnumProperty(string id)
            : base(id)
        {
            FieldType = "TEnum";
        }

        [DataMember, ReadOnly(true), Description("Use values from an existing Enum type in a control")]
        public string EnumType
        {
            set { enumType = value; }
            get { return enumType; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldEnumProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldDateProperty : TableFieldProperty
    {
        public TableFieldDateProperty()
        {
            FieldType = "TDate";
        }

        public TableFieldDateProperty(string id)
            : base(id)
        {
            FieldType = "TDate";
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldDateProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldTimeProperty : TableFieldProperty
    {
        public TableFieldTimeProperty()
        {
            FieldType = "TTime";
        }

        public TableFieldTimeProperty(string id)
            : base(id)
        {
            FieldType = "TTime";
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldTimeProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldContainerProperty : TableFieldProperty
    {
        public TableFieldContainerProperty()
        {
            FieldType = "TContainer";
        }

        public TableFieldContainerProperty(string id)
            : base(id)
        {
            FieldType = "TContainer";
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldContainerProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TableFieldInt64Property : TableFieldIntProperty
    {
        public TableFieldInt64Property()
        {
            FieldType = "TInt64";
        }

        public TableFieldInt64Property(string id)
            : base(id)
        {
            FieldType = "TInt64";
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(TableFieldInt64Property));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #region MENU

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class MenuItemProperty : HelpTextProperty
    {
        private string calledClass = string.Empty;
        private string calledObject = string.Empty;
        private string parameters = string.Empty;
        private string enumTypeParameter = string.Empty;
        private string enumParameter = string.Empty;
        private string neededAcessLevel = PropertyValue.NoAccess;
        private string web = string.Empty;
        private bool webSecureTransaction;
        private string webPage = string.Empty;
        private bool multiSelect;

        public MenuItemProperty()
        {
        }

        public MenuItemProperty(string id)
            : base(id)
        {
        }

        [DataMember, Description("Define which class was called")]
        public string Class
        {
            set { calledClass = value; }
            get { return calledClass; }
        }

        private string subPath = string.Empty;

        [DataMember]
        public string SubPath
        {
            set { subPath = value; }
            get { return subPath; }
        }

        [DataMember, Description("Define which object was called")]
        public string Object
        {
            set { calledObject = value; }
            get { return calledObject; }
        }

        [DataMember, Description("Custom parameters")]
        public string Parameters
        {
            set { parameters = value; }
            get { return parameters; }
        }

        [DataMember, Description("Custom enum type parameters")]
        public string EnumTypeParameter
        {
            set { enumTypeParameter = value; }
            get { return enumTypeParameter; }
        }

        [DataMember, Description("Custom enu parameters")]
        public string EnumParameter
        {
            set { enumParameter = value; }
            get { return enumParameter; }
        }

        [TypeConverter(typeof(NeededAcessLevel)), DataMember, Description("Needed access level to enable this item")]
        public string NeededAcessLevel
        {
            set { neededAcessLevel = value; }
            get { return neededAcessLevel; }
        }

        [DataMember, Description("Used only the class is set to web")]
        public string Web
        {
            set { web = value; }
            get { return web; }
        }

        [DataMember, Description("Does the menu item require SSL?")]
        public bool WebSecureTransaction
        {
            set { webSecureTransaction = value; }
            get { return webSecureTransaction; }
        }

        [DataMember, Description("Spcify which Web Pabe is linked to this menu function ")]
        public string WebPage
        {
            set { webPage = value; }
            get { return webPage; }
        }

        [DataMember,
         Description("Determines whether a user can run this Mene Item when making multiple record selections in Forms")
        ]
        public bool MultiSelect
        {
            set { multiSelect = value; }
            get { return multiSelect; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(MenuItemProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class MenuProperty : HelpTextProperty
    {
        private string neededAccessLevel = PropertyValue.NoAccess;
        private bool setCompany;
        private string type = "Menu";

        public MenuProperty()
        {
        }

        public MenuProperty(string id)
            : base(id)
        {
        }

        [DataMember, TypeConverter(typeof(NeededAcessLevel)), Description("Needed access level to enable this item")]
        public string NeededAccessLevel
        {
            set { neededAccessLevel = value; }
            get { return neededAccessLevel; }
        }

        [DataMember, Description("Set the default company each time the form is activated?")]
        public bool SetCompany
        {
            set { setCompany = value; }
            get { return setCompany; }
        }

        [DataMember, Browsable(false)]
        public string Type
        {
            set { type = value; }
            get { return type; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(MenuProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class MenuItemInMenuProperty : NameProperty
    {
        private string menuItemName = string.Empty;
        private string type = "MenuItem";

        public MenuItemInMenuProperty()
        {
        }

        public MenuItemInMenuProperty(string id)
            : base(id)
        {
        }

        [DataMember, Description("The name of the menu item to run")]
        public string MenuItemName
        {
            set { menuItemName = value; }
            get { return menuItemName; }
        }

        [DataMember, Browsable(false)]
        public string Type
        {
            set { type = value; }
            get { return type; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(MenuItemInMenuProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #region Enum

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class BaseEnumProperty : HelpTextProperty
    {
        private string displayLength = PropertyValue.Auto;
        private string style = PropertyValue.ComboBox;
        private bool useEnumValue;

        public BaseEnumProperty()
        {
        }

        public BaseEnumProperty(string id)
            : base(id)
        {
        }

        [DataMember, Description("Supply length of field, in number of characters")]
        public string DisplayLength
        {
            set { displayLength = value; }
            get { return displayLength; }
        }

        [DataMember, TypeConverter(typeof(BaseEnumStyle)), Description("How to display field?")]
        public string Style
        {
            set { style = value; }
            get { return style; }
        }

        [DataMember, Description("Use value properties on enum values (False means auto generate values)")]
        public bool UseEnumValue
        {
            set { useEnumValue = value; }
            get { return useEnumValue; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(BaseEnumProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class BaseEnumElementProperty : NameProperty
    {
        private uint enumValue;

        public BaseEnumElementProperty()
        {
        }

        public BaseEnumElementProperty(string id)
            : base(id)
        {
        }

        [DataMember, Description("Integer value for this enum selection (Between 0 and 250)")]
        public uint EnumValue
        {
            set { enumValue = value; }
            get { return enumValue; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(BaseEnumElementProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #region Form

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class FormProperty : NameProperty
    {
        public FormProperty()
        {
        }

        public FormProperty(string id)
            : base(id)
        {
        }

        private string category;

        [DataMember]
        public string Category
        {
            set { category = value; }
            get { return category; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(FormProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class FormDesignProperty : BaseProperty
    {
        public FormDesignProperty()
        {
        }

        public FormDesignProperty(string id)
            : base(id)
        {
        }

        private string left = PropertyValue.Auto;

        [DataMember, Description("Horizontal position of form or control")]
        public string Left
        {
            set { left = value; }
            get { return left; }
        }

        private string top = PropertyValue.Auto;

        [DataMember, Description("Vertical position of form or control")]
        public string Top
        {
            set { top = value; }
            get { return top; }
        }

        private string width = PropertyValue.Auto;

        [DataMember, Description("Width of form or control")]
        public string Width
        {
            set { width = value; }
            get { return width; }
        }

        private string height = PropertyValue.Auto;

        [DataMember, Description("Length of form or control")]
        public string Height
        {
            set { height = value; }
            get { return height; }
        }

        private bool visible = true;

        [DataMember, Description("Whether the control is visible?")]
        public bool Visible
        {
            set { visible = value; }
            get { return visible; }
        }

        private string caption = string.Empty;

        [DataMember, Editor(typeof(LabelPropertyEditor), typeof(UITypeEditor)), Description("The form's caption text")
        ]
        public string Caption
        {
            set { caption = value; }
            get { return caption; }
        }

        private bool maximizeBox = true;

        [DataMember,
         Description("Determines whether a form has a maximize box in the upper-right corner of its caption bar")]
        public bool MaximizeBox
        {
            set { maximizeBox = value; }
            get { return maximizeBox; }
        }

        private bool minimizeBox = true;

        [DataMember,
         Description("Determines whether a form has a minimize box in the upper-right corner of its caption bar")]
        public bool MinimizeBox
        {
            set { minimizeBox = value; }
            get { return minimizeBox; }
        }

        private string frame = PropertyValue.Standard;

        [DataMember, Description("Form frame style"), TypeConverter(typeof(FormDesignFrameStyle))]
        public string Frame
        {
            set { frame = value; }
            get { return frame; }
        }

        private string windowsResize = PropertyValue.Auto;

        [DataMember, Description("Allow resize of the form window"), TypeConverter(typeof(FormDesignWindowResize))]
        public string WindowResize
        {
            set { windowsResize = value; }
            get { return windowsResize; }
        }

        private string windowType = PropertyValue.Standard;

        [DataMember, Description("Type of form window"), TypeConverter(typeof(FormDesignWindowType))]
        public string WindowType
        {
            set { windowType = value; }
            get { return windowType; }
        }

        private bool saveSize;

        [DataMember, Description("Save size of form")]
        public bool SaveSize
        {
            set { saveSize = value; }
            get { return saveSize; }
        }

        private bool alwaysOnTop;

        [DataMember, Description("Should the form alway be displayed as the top window?")]
        public bool AlwaysOnTop
        {
            set { alwaysOnTop = value; }
            get { return alwaysOnTop; }
        }

        private bool hideToolBar;

        [DataMember, Description("Hide form-specific buttons on the toolbar")]
        public bool HideToolBar
        {
            set { hideToolBar = value; }
            get { return hideToolBar; }
        }

        private bool setCompany = true;

        [DataMember, Description("Set the default company each time the form is activated?")]
        public bool SetCompany
        {
            set { setCompany = value; }
            get { return setCompany; }
        }

        private string colorScheme = PropertyValue.Default;

        [DataMember, Description("Color setting"), TypeConverter(typeof(ColorScheme))]
        public string ColorScheme
        {
            set { colorScheme = value; }
            get { return colorScheme; }
        }

        private string imageName = string.Empty;

        [DataMember, TypeConverter(typeof(SysPropertyFileNameEditor)),
         Description("File name of bitmap to be displayed")]
        public string ImageName
        {
            set { imageName = value; }
            get { return imageName; }
        }

        private uint imageResource;

        [DataMember, Description("Resource ID")]
        public uint ImageResource
        {
            set { imageResource = value; }
            get { return imageResource; }
        }

        private string imageMode = PropertyValue.Normal;

        [DataMember, TypeConverter(typeof(FormDesignImageMode)), Description("Controls how the image is shown")]
        public string ImageMode
        {
            set { imageMode = value; }
            get { return imageMode; }
        }

        private string mode = PropertyValue.Watch;

        [DataMember, TypeConverter(typeof(FormDesignMode)), Description("Data entry mode")]
        public string Mode
        {
            set { mode = value; }
            get { return mode; }
        }

        private bool allowDocking;

        [DataMember, Description("Allow the form to be blued to the edges of the main window")]
        public bool AllowDocking
        {
            set { allowDocking = value; }
            get { return allowDocking; }
        }

        private string font = string.Empty;

        [DataMember, Editor(typeof(SysPropertyFontEditor), typeof(UITypeEditor)),
         Description("Font name for text in control")]
        public string Font
        {
            set { font = value; }
            get { return font; }
        }

        private string labelFont = string.Empty;

        [DataMember, Editor(typeof(SysPropertyFontEditor), typeof(UITypeEditor)),
         Description("The font name for the label of the control")]
        public string LabelFont
        {
            set { labelFont = value; }
            get { return labelFont; }
        }

        private string dataSource = string.Empty;

        [DataMember, Description("Table used as data source")]
        public string DataSource
        {
            set { dataSource = value; }
            get { return dataSource; }
        }

        private string topMargin = PropertyValue.Auto;

        [DataMember, Description("Size of top margin")]
        public string TopMargin
        {
            set { topMargin = value; }
            get { return topMargin; }
        }

        private string bottomMargin = PropertyValue.Auto;

        [DataMember, Description("Size of bottom margin")]
        public string BottomMargin
        {
            set { bottomMargin = value; }
            get { return bottomMargin; }
        }

        private string leftMargin = PropertyValue.Auto;

        [DataMember, Description("Size of left margin")]
        public string LeftMargin
        {
            set { leftMargin = value; }
            get { return leftMargin; }
        }

        private string rightMargin = PropertyValue.Auto;

        [DataMember, Description("Size of right margin")]
        public string RightMargin
        {
            set { rightMargin = value; }
            get { return rightMargin; }
        }

        private string arrangeWhen = PropertyValue.Default;

        [DataMember, TypeConverter(typeof(FormDesignArrangeWhen)),
         Description("When do you ant control on the container control to be arranged?")]
        public string ArrangeWhen
        {
            set { arrangeWhen = value; }
            get { return arrangeWhen; }
        }

        private string arrangeMethod = PropertyValue.Vertical;

        [DataMember, TypeConverter(typeof(FormDesignArrangeMothed)),
         Description("How do you want control on the container control to be arranged?")]
        public string ArrangeMethod
        {
            set { arrangeMethod = value; }
            get { return arrangeMethod; }
        }

        private uint columns = 1;

        [DataMember, Description("Number of columns")]
        public uint Columns
        {
            set { columns = value; }
            get { return columns; }
        }

        private string columnspace = PropertyValue.Auto;

        [DataMember, Description("Space between columns")]
        public string Columnspace
        {
            set { columnspace = value; }
            get { return columnspace; }
        }

        private bool hideIfEmpty = true;

        [DataMember, Description("Auto hide the container if all contained controls are non-visible")]
        public bool HideIfEmpth
        {
            set { hideIfEmpty = value; }
            get { return hideIfEmpty; }
        }

        private bool alignChildren = true;

        [DataMember, Description("Align child controls?")]
        public bool AlignChildren
        {
            set { alignChildren = value; }
            get { return alignChildren; }
        }

        private bool alignChild = true;

        [DataMember, Description("Inclued in general alignment?")]
        public bool AlignChild
        {
            set { alignChild = value; }
            get { return alignChild; }
        }

        private bool allowUserSetup = true;

        [DataMember, Description("Is user setup allowed for this element?")]
        public bool AllowUserSetup
        {
            set { allowUserSetup = value; }
            get { return allowUserSetup; }
        }

        private string needAccessLevel = PropertyValue.NoAccess;

        [DataMember, TypeConverter(typeof(NeededAcessLevel)), Description("Needed access level to enable this item")]
        public string NeedAccessLevel
        {
            set { needAccessLevel = value; }
            get { return needAccessLevel; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(FormDesignProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    /*
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class FormQueryProperty : BaseProperty
    {
        private string query = string.Empty;
        [DataMember, Description("Query")]
        public string Query
        {
            get { return query; }
            set { query = value; }
        }

    } //yujie.zhou
    */


    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class WinControlProperty : NameProperty
    {
        #region 构造函数

        /// <summary>
        /// Default Instructor
        /// </summary>
        public WinControlProperty()
        {
            init();
        }

        /// <summary>
        /// Instructior
        /// </summary>
        /// <param name="id"></param>
        public WinControlProperty(string id)
            : base(id)
        {
            init();
        }

        #endregion

        private void init()
        {
            SetControlType();
        }

        [DataMember]
        public string ControlType;

        protected virtual void SetControlType()
        {
        }

        #region 属性

        private bool autoDeclaration;

        [DataMember,
         Description("Automatic declaration of a member variable to the object, using the name of the object?")]
        public bool AutoDeclaration
        {
            set { autoDeclaration = value; }
            get { return autoDeclaration; }
        }

        private bool visiable = true;

        [DataMember, Description("Make control visiable?")]
        public bool Visiable
        {
            set { visiable = value; }
            get { return visiable; }
        }

        private bool allowEdit = true;

        [DataMember, Description("Can data be modified with this control")]
        public bool AllowEdit
        {
            set { allowEdit = value; }
            get { return allowEdit; }
        }

        private string left = PropertyValue.AutoLeft;

        [DataMember, Description("Horizontal position of form or control"), TypeConverter(typeof(ControlLeftList)),
         QuotableString]
        public string Left
        {
            set { left = value; }
            get { return left; }
        }

        private string top = PropertyValue.Auto;

        [DataMember, Description("Vertical position of form or control"), TypeConverter(typeof(ControlTopList))]
        public string Top
        {
            set { top = value; }
            get { return top; }
        }

        private string width = PropertyValue.Auto;

        [DataMember, Description("Width of form or control"), TypeConverter(typeof(ControlWidthAndHeightList))]
        public string Width
        {
            set { width = value; }
            get { return width; }
        }

        private string height = PropertyValue.Auto;

        [DataMember, Description("Height of form or control"), TypeConverter(typeof(ControlWidthAndHeightList))]
        public string Height
        {
            set { height = value; }
            get { return height; }
        }

        private string verticalSpace = PropertyValue.Auto;

        [DataMember, Description("Space above and below control")]
        public string VerticalSpace
        {
            set { verticalSpace = value; }
            get { return verticalSpace; }
        }

        private bool enabled = true;

        [DataMember, Description("Enabl control?")]
        public bool Enabled
        {
            set { enabled = value; }
            get { return enabled; }
        }

        private bool skip = true;

        [DataMember, Description("Skip control?")]
        public bool Skip
        {
            set { skip = value; }
            get { return skip; }
        }

        private bool alignControl;

        [DataMember, Description("Align control?")]
        public bool AlignControl
        {
            set { alignControl = value; }
            get { return alignControl; }
        }

        private string dragDrop = PropertyValue.None;

        [DataMember, Description("Drag and drop behavior"), TypeConverter(typeof(ControlDragDropList))]
        public string DragDrop
        {
            set { dragDrop = value; }
            get { return dragDrop; }
        }

        private string dock = ""; //yujie.zhou

        [DataMember, Description("N"), TypeConverter(typeof(ControlWidthAndHeightList))]
        public string Dock
        {
            set { dock = value; }
            get { return dock; }
        }

        #endregion
    } //yujie.zhou

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TabProperty : WinControlProperty
    {
        protected override void SetControlType()
        {
            ControlType = "RuleTabControl";
            base.SetControlType();
        }
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TabPageProperty : WinControlProperty
    {
        protected override void SetControlType()
        {
            ControlType = "RuleTabPage";
            base.SetControlType();
        }

        private bool columns;

        [DataMember, Description("Align control?")]
        public bool Columns
        {
            set { columns = value; }
            get { return columns; }
        }
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class GridProperty : WinControlProperty
    {
        protected override void SetControlType()
        {
            ControlType = "RuleDataGridView";
            base.SetControlType();
        }

        private string dataSource = string.Empty;

        [DataMember, Description("The table as datasource")]
        public string DataSource
        {
            get { return dataSource; }
            set { dataSource = value; }
        }
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class GroupProperty : NameProperty
    {
        private string dataSource = string.Empty;

        [DataMember, Description("The table as datasource"), TypeConverter(typeof(TableCollection))]
        public string DataSource
        {
            get { return dataSource; }
            set { dataSource = value; }
        }

        private string dataGroup = string.Empty;

        [DataMember, Description("The group in the table as datasource"), TypeConverter(typeof(TableGroup))]
        public string DataGroup
        {
            get { return dataGroup; }
            set { dataGroup = value; }
        }

        private int columnIdx;

        [DataMember, Description("Set the position when the container has several columns, 0 means auto.")]
        public int ColumnIdx
        {
            get { return columnIdx; }
            set { columnIdx = value; }
        }
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class TreeProperty : WinControlProperty
    {
        #region Properties

        private string dataSource = string.Empty;

        [DataMember, Description("The table as datasource")]
        public string DataSource
        {
            get { return dataSource; }
            set { dataSource = value; }
        }

        private string keyField = string.Empty;

        [DataMember, Description("")]
        public string KeyField
        {
            get { return keyField; }
            set { keyField = value; }
        }

        private string parentField = string.Empty;

        [DataMember, Description("")]
        public string ParentField
        {
            get { return parentField; }
            set { parentField = value; }
        }

        #endregion

        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "RuleTreeView";
            base.SetControlType();
        }

        #endregion
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class FilterProperty : WinControlProperty
    {
        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "QueryFilter";
            base.SetControlType();
        }

        #endregion
    } //yujie.zhou
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class SplitProperty : WinControlProperty
    {
        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "None";
            base.SetControlType();
        }

        #endregion
    } //yujie.zhou


    public class ButtonProperty : WinControlProperty
    {
        /// <summary>
        /// Default Instructor
        /// </summary>
        public ButtonProperty()
        {
        }

        /// <summary>
        /// Instructior
        /// </summary>
        /// <param name="id"></param>
        public ButtonProperty(string id)
            : base(id)
        {
        }

        #region Properties

        private string buttonDisplay = PropertyValue.Text;

        [DataMember, Description("The apperance of the button"), TypeConverter(typeof(ButtonDisplayList))]
        public string ButtonDisplay
        {
            set { buttonDisplay = value; }
            get { return buttonDisplay; }
        }

        private string normalImage = string.Empty;

        [DataMember, Description("The image to be displayed when the control is enabled")]
        public string NormalImage
        {
            get { return normalImage; }
            set { normalImage = value; }
        }

        private uint normalResource;

        [DataMember, Description("The image (by resource ID) to display when the control is enabled")]
        public uint NormalResource
        {
            set { normalResource = value; }
            get { return normalResource; }
        }

        private string disabledImage = string.Empty;

        [DataMember, Description("The image to be displayed when the control is disabled")]
        public string DisabledImage
        {
            set { disabledImage = value; }
            get { return disabledImage; }
        }

        private uint disabledResource;

        [DataMember, Description("The image (by resource ID) to display when the control is disabled")]
        public uint DisabledResource
        {
            set { disabledResource = value; }
            get { return disabledResource; }
        }

        private string font = string.Empty;

        [DataMember, Description("Font name for text in control"),
         Editor(typeof(SysPropertyFontEditor), typeof(UITypeEditor))]
        public string Font
        {
            set { font = value; }
            get { return font; }
        }

        private uint fontSize;

        [DataMember, Description("Font size for text in contol")]
        public uint FontSize
        {
            set { fontSize = value; }
            get { return fontSize; }
        }

        private bool italic;

        [DataMember, Description("Do you want the text in the control to be italicized")]
        public bool Italic
        {
            set { italic = value; }
            get { return italic; }
        }

        private bool underline;

        [DataMember, Description("Do you want the text in the control to be underlined")]
        public bool Underline
        {
            set { underline = value; }
            get { return underline; }
        }

        private string bold = PropertyValue.Default;

        [DataMember, Description("The type of bold for the text in the control")]
        public string Bold
        {
            set { bold = value; }
            get { return bold; }
        }

        private string border = PropertyValue.Auto;

        [DataMember, Description("The style of the borderline of the control")]
        public string Border
        {
            set { border = value; }
            get { return border; }
        }

        private bool showShortcut = true;

        [DataMember, Description("Should the control reserve and display a shortcut litter")]
        public bool ShowShortcut
        {
            set { showShortcut = value; }
            get { return showShortcut; }
        }

        private bool defaultButton;

        [DataMember, Description("Is this the default button?")]
        public bool DefaultButton
        {
            get { return defaultButton; }
            set { defaultButton = value; }
        }

        private bool saveRecord = true;

        [DataMember,
         Description("If Yes, changes in the current record are saved before the button's command is activated")]
        public bool SaveRecord
        {
            set { saveRecord = value; }
            get { return saveRecord; }
        }

        private string multiSelect = PropertyValue.Auto;

        [DataMember,
         Description("Determines whether a user can use this button when making multiple record selections in Forms"),
         TypeConverter(typeof(AutoYesNoProperty))]
        public string MultiSelect
        {
            get { return multiSelect; }
            set { multiSelect = value; }
        }

        private string colorSchema = PropertyValue.Default;

        [DataMember, Description("Color setting"), TypeConverter(typeof(ColorScheme))]
        public string ColorSchema
        {
            set { colorSchema = value; }
            get { return colorSchema; }
        }

        private string backStyle = PropertyValue.Opaque;

        [DataMember, Description("Stype of control's background"), TypeConverter(typeof(BackStyle))]
        public string BackStyle
        {
            set { backStyle = value; }
            get { return backStyle; }
        }

        private string backgroundColor = PropertyValue.Auto;

        [DataMember, Description("Color of control's background")]
        public string BackgroundColor
        {
            set { backgroundColor = value; }
            get { return backgroundColor; }
        }

        private string foregroundColor = PropertyValue.Auto;

        [DataMember, Description("Color of control's foreground")]
        public string ForegroundColor
        {
            get { return foregroundColor; }
            set { foregroundColor = value; }
        }

        private string neededAccessLevel = PropertyValue.View;

        [DataMember, Description("Needed access level to enable this menu function"),
         TypeConverter(typeof(NeededAcessLevel))]
        public string NeededAccessLevel
        {
            get { return neededAccessLevel; }
            set { neededAccessLevel = value; }
        }

        #endregion

        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "RuleButton";
            base.SetControlType();
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(ButtonProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }

        #endregion
    }

    public class MenuItemButtonProperty : ButtonProperty
    {
        #region Constructors

        public MenuItemButtonProperty()
        {
        }

        public MenuItemButtonProperty(string id)
            : base(id)
        {
        }

        #endregion

        #region Properties

        private string menuItemType = PropertyValue.Display;

        [DataMember, Description("Select which type of menu item to run"),
         TypeConverter(typeof(MenuItemTypeCollection))]
        public string MenuItemType
        {
            set { menuItemType = value; }
            get { return menuItemType; }
        }

        private string menuItemName = string.Empty;

        [DataMember, Description("The name of the menu item to run")]
        public string MenuItemName
        {
            set { menuItemName = value; }
            get { return menuItemName; }
        }

        private string dataSource = string.Empty;

        [DataMember, Description("Table used as data source")]
        public string DataSource
        {
            set { dataSource = value; }
            get { return dataSource; }
        }

        #endregion

        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "RuleMenuButton";
            base.SetControlType();
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(MenuItemButtonProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }

        #endregion
    }

    public class PanelProperty : WinControlProperty
    {
        #region Override Methods

        protected override void SetControlType()
        {
            ControlType = "RulePanel";
            base.SetControlType();
        }
    }

        #endregion

    #region Query

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryProperty : NameProperty
    {
        public QueryProperty()
        {
        }

        public QueryProperty(string id)
            : base(id)
        {
        }

        private string form = PropertyValue.SysQueryForm;

        [DataMember, ReadOnly(true), Description("Specify the name of the form used for user interaction")]
        public string Form
        {
            set { form = value; }
            get { return form; }
        }

        private bool userUpdate = true;

        [DataMember, Description("May the user update the query")]
        public bool UserUpdate
        {
            set { userUpdate = value; }
            get { return userUpdate; }
        }

        private int version = 1;

        [DataMember, ReadOnly(true), Description("Internal version number")]
        public int Version
        {
            set { version = value; }
            get { return version; }
        }

        private string literals = PropertyValue.Default;

        [DataMember, TypeConverter(typeof(QueryLiterals)),
         Description("Specifies how literals are represented in the SQL statements")]
        public string Literals
        {
            set { literals = value; }
            get { return literals; }
        }

        private bool interactive = true;

        [DataMember,
         Description("Specify whether or not this query may open dialogs to delimit records and set up printers etc.")]
        public bool Interactive
        {
            set { interactive = value; }
            get { return interactive; }
        }

        private bool allowCheck;

        [DataMember, Description("Allow checking of table rights")]
        public bool AllowCheck
        {
            set { allowCheck = value; }
            get { return allowCheck; }
        }

        private string string1 = string.Empty;

        [DataMember]
        public string String1
        {
            set { string1 = value; }
            get { return string1; }
        }

        private string string2 = string.Empty;

        [DataMember]
        public string String2
        {
            set { string2 = value; }
            get { return string2; }
        }

        private string string3 = string.Empty;

        [DataMember]
        public string String3
        {
            set { string3 = value; }
            get { return string3; }
        }

        private string category = string.Empty;

        [DataMember]
        public string Category
        {
            set { category = value; }
            get { return category; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryDataSourceProperty : NameProperty
    {
        public QueryDataSourceProperty()
        {
        }

        public QueryDataSourceProperty(string id)
            : base(id)
        {
        }

        private string table = string.Empty;

        [DataMember, ReadOnly(true), TypeConverter(typeof(TableCollection)), Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        private string company = string.Empty;

        [DataMember, Description("Get data from which company?")]
        public string Company
        {
            set { company = value; }
            get { return company; }
        }

        private bool firstOnly;

        [DataMember, Description("Only the first record?")]
        public bool FirstOnly
        {
            set { firstOnly = value; }
            get { return firstOnly; }
        }

        private bool firstFast;

        [DataMember, Description("Retrieve the first record faster than the next?")]
        public bool FirstFast
        {
            set { firstFast = value; }
            get { return firstFast; }
        }

        private string allowAdd = PropertyValue.AllFields;

        [DataMember, TypeConverter(typeof(QueryDataSourceAllowAdd)),
         Description("Enter which fields the user may add for search")]
        public string AllowAdd
        {
            set { allowAdd = value; }
            get { return allowAdd; }
        }

        private string orderMode = PropertyValue.OrderBy;

        [DataMember, TypeConverter(typeof(QueryDataSourceOrderMode)),
         Description("Specify whether records should be sorted or grouped")]
        public string OrderMode
        {
            set { orderMode = value; }
            get { return orderMode; }
        }

        private bool update;

        [DataMember, Description("Specify whether the cursor can update records in the database")]
        public bool Update
        {
            set { update = value; }
            get { return update; }
        }

        private bool enabled = true;

        [DataMember, Description("Specify whehter the datasource shoueld be ignored")]
        public bool Enabled
        {
            set { enabled = value; }
            get { return enabled; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryDataSourceProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryDataSourceFieldsProperty : BaseProperty
    {
        public QueryDataSourceFieldsProperty()
        {
        }

        public QueryDataSourceFieldsProperty(string id)
            : base(id)
        {
        }

        private bool dynamic = true;

        [DataMember, Description("Defines whether the field list is defined by the table's field list")]
        public bool Dynamic
        {
            set { dynamic = value; }
            get { return dynamic; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryDataSourceFieldsProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryDataSourceFieldProperty : BaseProperty
    {
        public QueryDataSourceFieldProperty()
        {
        }

        public QueryDataSourceFieldProperty(string id)
            : base(id)
        {
        }

        private string table = string.Empty;

        [ReadOnly(true), DataMember, Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        private string field = string.Empty;

        [DataMember, Description("The field participating in the aggregate function")]
        public string Field
        {
            set { field = value; }
            get { return field; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryDataSourceFieldProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryDataSourceSortingFieldProperty : BaseProperty
    {
        public QueryDataSourceSortingFieldProperty()
        {
        }

        public QueryDataSourceSortingFieldProperty(string id)
            : base(id)
        {
        }

        private string table = string.Empty;

        [DataMember, ReadOnly(true), Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        private string field = string.Empty;

        [DataMember, Description("Field being sorted"), TypeConverter(typeof(QueryDataSourceTableFieldsList))]
        public string Field
        {
            set { field = value; }
            get { return field; }
        }

        private string ordering = PropertyValue.Ascending;

        [DataMember, Description("Sorting of records for this field"),
         TypeConverter(typeof(QueryDataSourceFieldSortingMode))]
        public string Ordering
        {
            set { ordering = value; }
            get { return ordering; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryDataSourceSortingFieldProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class QueryDataSourceRangProperty : NameProperty
    {
        public QueryDataSourceRangProperty()
        {
        }

        public QueryDataSourceRangProperty(string id)
            : base(id)
        {
        }

        private string table = string.Empty;

        [DataMember, ReadOnly(true), Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }

        private string field = string.Empty;

        [DataMember, Description("Field whoes values limit the recoreds"),
         TypeConverter(typeof(QueryDataSourceTableFieldsList))]
        public string Field
        {
            set { field = value; }
            get { return field; }
        }

        private string _value = string.Empty;

        [DataMember, Description("Specify which records are to be retrieved")]
        public string Value
        {
            set { _value = value; }
            get { return _value; }
        }

        private string status = PropertyValue.Open;

        [DataMember, Description("Are the field Open, Lock or Hide"),
         TypeConverter(typeof(QueryDataSourceRangeStatusMode))]
        public string Status
        {
            set { status = value; }
            get { return status; }
        }

        private bool enabled = true;

        [DataMember, Description("Specify whether the field is to be ignored")]
        public bool Enabled
        {
            set { enabled = value; }
            get { return enabled; }
        }

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(QueryDataSourceRangProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    #endregion

    #endregion
#region WebForm
    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class WebFormProperty : HelpTextProperty
    {
        //the EDTProperty class add extends and aligment properties.
        public WebFormProperty()
        {
        }

        public WebFormProperty(string id)
            : base(id)
        {
            //this.ID = id;
        }

        /*private string name;
        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }*/
        /* private string helpText;
         [DataMember]
         public string HelpText
         {
             set { helpText = value; }
             get { return helpText; }
         }*/
        private string formHelp = string.Empty;

        [DataMember, Description("The form to lookup from fields in forms")]
        public string FormHelp
        {
            set { formHelp = value; }
            get { return formHelp; }
        }

        //private string arrayLength;

        //[DataMember, ReadOnly(true), Description("Number of element in array")]
        //public string ArrayLength
        //{
        //    set { arrayLength = value; }
        //    get { return arrayLength; }
        //}

        //private string displayLength = PropertyValue.Auto;

        //[DataMember, Description("Number of characters to show in form/report")]
        //public string DisplayLength
        //{
        //    set { displayLength = value; }
        //    get { return displayLength; }
        //}

        //private string buttonImage = PropertyValue.Arrow;

        //[DataMember, Description("The image to appear on a lookup button in forms"),
        // TypeConverter(typeof(EDTButtonImage))]
        //public string ButtonImage
        //{
        //    set { buttonImage = value; }
        //    get { return buttonImage; }
        //}

        //private string extends = string.Empty;

        //[DataMember, Description("The object to be inherited")]
        //public string Extends
        //{
        //    set { extends = value; }
        //    get { return extends; }
        //}

        //private string alignment = PropertyValue.Auto;

        //[TypeConverter(typeof(AlignmentCollection)), DataMember, Description("Alignment of value displayed in control")
        //]
        //public string Alignment
        //{
        //    set { alignment = value; }
        //    get { return alignment; }
        //}

        //protected string edtType;

        //[DataMember, ReadOnly(true), Description("The primitive type name")]
        //public string EDTType
        //{
        //    get { return edtType; }
        //    set { edtType = value; }
        //}
        private string table = string.Empty;

        [DataMember, ReadOnly(false), TypeConverter(typeof(TableCollection)), Description("Table used as data source")]
        public string Table
        {
            set { table = value; }
            get { return table; }
        }
        //应使用override而不是new，以便调用方法时能使用最新的方法版本。
        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(WebFormProperty));
            FileStream writer = getFileWriter();
            ser.WriteObject(writer, this);
            writer.Close();
        }
    }

    [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class WebFormSingleProperty : WebFormProperty
    {
        public WebFormSingleProperty(string id)
            : base(id)
        {
            //this.ID = id;
            //EDTType = "TString";
        }

        public WebFormSingleProperty()
        {
            //EDTType = "TString";
        }
       

        //private string displayHeight = PropertyValue.Auto;

        //[DataMember, Description("Number of lines to show in form/report")]
        //public string DisplayHeight
        //{
        //    set { displayHeight = value; }
        //    get { return displayHeight; }
        //}

        //private uint stringSize = 20;

        //[DataMember, Description("Length of line in number of characters")]
        //public uint StringSize
        //{
        //    set { stringSize = value; }
        //    get { return stringSize; }
        //}

        //private string adjustment = PropertyValue.Auto;

        //[DataMember, Description("Relational characteristics of text in terms of alignment"),
        // TypeConverter(typeof(AlignmentCollection))]
        //public string Adjustment
        //{
        //    set { adjustment = value; }
        //    get { return adjustment; }
        //}

        //private string changeCase = PropertyValue.None;

        //[DataMember, Description("Changed case of input text"), TypeConverter(typeof(EDTStringChangeCase))]
        //public string ChangeCase
        //{
        //    set { changeCase = value; }
        //    get { return changeCase; }
        //}

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(WebFormSingleProperty));
            FileStream writer = getFileWriter();

            ser.WriteObject(writer, this);
            writer.Close();
        }
    }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
    public class WebFormMasterSlaveProperty : WebFormProperty
    {
        public WebFormMasterSlaveProperty(string id)
            : base(id)
        {
            //this.ID = id;
            //EDTType = "TString";
        }

        public WebFormMasterSlaveProperty()
        {
            //EDTType = "TString";
        }
       

        public override void SerializeToXML()
        {
            DataContractSerializer ser =
                new DataContractSerializer(typeof(WebFormMasterSlaveProperty));
            FileStream writer = getFileWriter();

            ser.WriteObject(writer, this);
            writer.Close();
        }
    }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormTreeProperty : WebFormProperty
     {
         public WebFormTreeProperty(string id)
             : base(id)
         {
            
         }

         public WebFormTreeProperty()
         {
            
         }
         private string id = string.Empty;

         [DataMember, ReadOnly(false), Description("Tree Node ID")]
         public string ID
         {
             set { id = value; }
             get { return id; }
         }
         private string pid = string.Empty;

         [DataMember, ReadOnly(false), Description("Parent Tree Node ID")]
         public string PID
         {
             set { pid = value; }
             get { return pid; }
         }

         private string nodeName = string.Empty;

         [DataMember, ReadOnly(false), Description("Node Name")]
         public string NodeName
         {
             set { nodeName = value; }
             get { return nodeName; }
         }
         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormTreeProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormParameterProperty : WebFormProperty
     {
         public WebFormParameterProperty(string id)
             : base(id)
         {

         }

         public WebFormParameterProperty()
         {

         }


         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormParameterProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormBlankProperty : HelpTextProperty
     {
         public WebFormBlankProperty(string id)
             : base(id)
         {

         }

         public WebFormBlankProperty()
         {

         }


         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormBlankProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormParaByUserProperty : WebFormProperty
     {
         public WebFormParaByUserProperty(string id)
             : base(id)
         {

         }

         public WebFormParaByUserProperty()
         {

         }
          private string user = string.Empty;
          [DataMember, ReadOnly(false), Description("User Name")]
         public string User
         {
             set { user = value; }
             get { return user; }
         }
        
         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormParaByUserProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormRelationProperty : WebFormProperty
     {
         public WebFormRelationProperty(string id)
             : base(id)
         {

         }

         public WebFormRelationProperty()
         {

         }
         private string midTable = string.Empty;
         [DataMember, ReadOnly(false),TypeConverter(typeof(TableCollection)), Description("Middle Table Name")]
         public string MiddleTable
         {
             set { midTable = value; }
             get { return midTable; }
         }

         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormRelationProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormFieldGroupProperty : HelpTextProperty
     {
         public WebFormFieldGroupProperty(string id)
             : base(id)
         {
             
         }

         public WebFormFieldGroupProperty()
         {
             
         }
         private string group = string.Empty;

         [DataMember, ReadOnly(false), TypeConverter(typeof(WebFormFieldGroupCollection)), Description("Input the Field Group Name")]
         public string FieldGroup
         {
             set { group = value; }
             get { return group; }
         }



         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormFieldGroupProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }
     [DataContract(Namespace = "http://RuleCode.ObjectTree.Property")]
     public class WebFormButtonProperty : HelpTextProperty
     {
         public WebFormButtonProperty(string id)
             : base(id)
         {

         }

         public WebFormButtonProperty()
         {

         }
         private string method = string.Empty;

         [DataMember, ReadOnly(false), Description("Input the Method Name")]
         public string Method
         {
             set { method = value; }
             get { return method; }
         }
         private string table = string.Empty;

         [DataMember, ReadOnly(false), TypeConverter(typeof(TableCollection)), Description("Table used as data source")]
         public string Table
         {
             set { table = value; }
             get { return table; }
         }


         public override void SerializeToXML()
         {
             DataContractSerializer ser =
                 new DataContractSerializer(typeof(WebFormButtonProperty));
             FileStream writer = getFileWriter();

             ser.WriteObject(writer, this);
             writer.Close();
         }
     }

#endregion

   



    public class ClassProperty : BaseProperty
    {
        public ClassProperty()
        {
        }

        public ClassProperty(string id)
            : base(id)
        {
        }

        //public override void SerializeToXML()
        //{
        //    DataContractSerializer ser =
        //        new DataContractSerializer(typeof(ClassProperty));
        //    FileStream writer = getFileWriter();
        //    ser.WriteObject(writer, this);
        //    writer.Close();
        //}
    }


    /// <summary>
    /// 用来标识属性中为String类型的属性要加引号
    /// </summary>
}